package com.project.lx.gettxtfilename.RxBus;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;

import com.orhanobut.logger.Logger;
import com.project.lx.baseproject.base.RxBus;
import com.project.lx.baseproject.util.ToastUtils;
import com.project.lx.gettxtfilename.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.functions.Consumer;

public class RxBus2Activity extends AppCompatActivity {

    @BindView(R.id.btn_bus_2)
    Button btnBus2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rx_bus2);
        ButterKnife.bind(this);
    }

    @OnClick(R.id.btn_bus_2)
    public void onViewClicked() {
        ToastUtils.showToast(this, "哈哈");

        RxBus rxBus = RxBus.getInstance();
        RxBus.getInstance().subscribe(String.class, new Consumer() {
            @Override
            public void accept(Object o) throws Exception {
                Logger.t("测试Bus").i(o.toString());
                btnBus2.setText(o.toString());
            }
        });
    }
}
